﻿using UnityEngine.UIElements;

namespace winS.UnityEditor.UIElement
{
    public class HelpBox : EditorControl
    {
        public float fontSize { get => label.style.fontSize.value.value; set => label.style.fontSize = value; }
        public string message { get => label.text; set => label.text = value; }

        private readonly Label label;

        internal HelpBox(ElementFactory elementFactory) : base(elementFactory)
        {
            style.SetBorder(elementFactory.splitlineColor, 1f, 4f);
            style.flexDirection = FlexDirection.Row;
            style.SetPadding(4f);

            Icon icon = EditorElementUtility.elementFactory.CreateIcon(PackageAssets.Icons.tips, 24f, ColorLevelUtility.GetColor(22));
            icon.style.flexShrink = 0f;
            Add(icon);

            Add(label = EditorElementUtility.elementFactory.CreateLabel(10f));
            label.style.flexShrink = -1f;
            label.style.whiteSpace = WhiteSpace.Normal;
            label.style.marginRight = elementFactory.labelMarginRight;
            label.style.marginLeft = 8f;
        }
    }
}